package zlx;

import com.alibaba.fastjson.JSONObject;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.Transaction;
//测试redis 事务

public class RedisTransaction {
    public static void main(String[] args) {
        Jedis jedis =new Jedis("127.0.0.1",6379);
        JSONObject jsons =new JSONObject();
        jsons.put("hello","world");
        jsons.put("name","zlx");
        String result =jsons.toJSONString();

        //开启事务
        Transaction transaction =jedis.multi();
        transaction.set("zlx1",result);
        transaction.set("zlx2",result);
        transaction.exec();
        jedis.close();


    }
}
